package com.lagou.dao.impl;

import com.lagou.dao.articleDao;
import com.lagou.domain.Article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository("articleDao")
public class articleDaoImpl implements articleDao {
    //注入jdbcTemplate
    @Autowired
    private JdbcTemplate jdbcTemplate;
    //重写add方法
    public void addArticle(Article article) {
        String sql = "INSERT INTO `springbootdata`.`t_article` (`id`, `title`, `content`) VALUES (null, ?, ?);";
        jdbcTemplate.update(sql,article.getTitle(),article.getContent());
        System.out.println("成功添加文章的信息");
    }
}
